package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 安慕希
 * Date: 2025-03-16
 * Time: 17:05
 */
public class Animal {
    String name;
    int age;
    public void eat(){
        System.out.println(this.name+"正在吃饭");
    }


    Animal dog2 = new Dog("小白", 2);//向上转型作用1.直接赋值
    //父类类型，子类引用

    public void function(Animal animal){
        //向上转型作用2，参数转递



        animal.eat();
    }






    //

}
